package com.shanzmoo.core.domain.vo;

import com.shanzmoo.db.module.msys.entity.MSysMenuEntity;
import com.shanzmoo.db.module.psys.entity.PSysMenuEntity;
import lombok.Data;

/**
 *
 *
 * @author： Gzhao 2021/3/28
 */
@Data
public class RouterAuthVO {

    private String path;
    private String name;
    private String component;
    private Meta meta;

    public static RouterAuthVO create(MSysMenuEntity menuEntity) {
        return create(
                menuEntity.getComponent(),
                menuEntity.getRouterName(),
                menuEntity.getPath(),
                menuEntity.getTitle(),
                menuEntity.getCache()
        );
    }

    public static RouterAuthVO create(PSysMenuEntity menuEntity) {
        return create(
                menuEntity.getComponent(),
                menuEntity.getRouterName(),
                menuEntity.getPath(),
                menuEntity.getTitle(),
                menuEntity.getCache()
        );
    }


    private static RouterAuthVO create(String component, String routerName, String path, String title, Boolean cache) {
        RouterAuthVO router = new RouterAuthVO();
        router.setComponent(component);
        router.setName(routerName);
        router.setPath(path);

        Meta meta = new Meta();
        meta.setTitle(title);
        meta.setCache(cache);
        router.setMeta(meta);

        return router;
    }

    @Data
    private static class Meta{
        private String title;
        private Boolean cache;
    }
}
